/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package br.com.trabalho;

import java.util.ArrayList;
import java.util.List;

/**
 *
 * @author Neylton
 */
public class Graph {

    private List<Node> nodes;

    public Graph() {
        nodes = new ArrayList<Node>();
    }

    public List<Node> getNodes() {
        return nodes;
    }

    public void setNodes(List<Node> nodes) {
        this.nodes = nodes;
    }
    
    public void addNode(Node n) {
        nodes.add(n);
    }
    
    public void removeNode(Node n) {
        nodes.remove(n);
    }
    
    public void readGraph(String path) {
        List<String> strList = File.readFile(path);
        
        for(String string : strList) {
            String str[] = string.split(" ");
            Node no = new Node();
            no.setLabel(Integer.parseInt(str[0]));
            
            int it = str.length;
            for(int i=1; i<it; i++) {
                Vertex vtx = new Vertex();
                vtx.setLabel(Integer.parseInt(str[i]));
                no.getAdjList().add(vtx);
            }
            nodes.add(no);
        }
    }
    
    public void printGraph() {
        for (Node node : nodes) {
            System.out.println(node);
        }
    }
    
}
